package szwolaiyun.paireach.com.szwolaizhuang.net;

import com.paireach.szwolaiyun.sz_util.LogUtil;
import com.paireach.szwolaiyun.sz_util.Md5;

import java.util.HashMap;
import java.util.Map;

import szwolaiyun.paireach.com.szwolaizhuang.model.requestTag.RequestTag;

/**
 * 用户请求
 */
public class UserRequest implements UserInterface {
    private static final String TAG = "UserRequest";

    @Override
    public void passwordLogin(String username, String password) {
        HashMap<String, String> map = new HashMap<>();
        map.put("workerName", username);
        try {
            map.put("workerPwd", Md5.getStringMD5(password));
        } catch (Exception e) {
            map.put("workerPwd", "");
        }
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "workerLogin.a", map, RequestTag.USER_LOGIN);
    }

    @Override
    public void passwordLogin_app(String username, String password) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", username);
        try {
            map.put("driverPwd", Md5.getStringMD5(password));
        } catch (Exception e) {
            map.put("driverPwd", "");
        }
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "loginForDriver.a", map, RequestTag.USER_LOGIN);
    }

    @Override
    public void passwordLogin_app2(String username, String password,String gpsStatus,String simSerialNumber,String simPhoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", username);
        map.put("gpsStatus", gpsStatus);
        map.put("simSerialNumber", simSerialNumber);
        map.put("simPhoneNumber", simPhoneNumber);
        try {
            map.put("driverPwd", Md5.getStringMD5(password));
        } catch (Exception e) {
            map.put("driverPwd", "");
        }
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "loginForDriver.a", map, RequestTag.USER_LOGIN);
    }
    @Override
    public void passwordLogin_app3(String loginData) {
        LogUtil.d(TAG,"loginData="+loginData);
        Map<String,String> map = new HashMap<>();
        map.put("loginData",loginData);
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "loginForDriver.a", map, RequestTag.USER_LOGIN);
    }

    @Override
    public void changePassword(String phone, String password) {
        HashMap<String, String> map = new HashMap<>();
        map.put("mobile", phone);
        try {
            map.put("newPwd", Md5.getStringMD5(password));
        } catch (Exception e) {
            map.put("newPwd", "");
        }
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "changeDriverPwd.a", map, RequestTag.CHANGE_PASSWORD);
    }

    @Override
    public void 获取叉车工列表(String operatorId) {
        HashMap<String, String> map = new HashMap<>();
        map.put("operatorId", operatorId);
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "queryAllForklift.a", map, RequestTag.获取叉车工列表);
    }

    @Override
    public void 保存叉车工(String workType, String operatorId, String partnerId, String orderCode) {
        HashMap<String, String> map = new HashMap<>();
        map.put("workType", workType);
        map.put("operatorId", operatorId);
        map.put("partnerId", partnerId);
        map.put("orderCode", orderCode);
        MainRequest.getInstance().makeStringPostRequest(BaseUrl.zhuang + "saveForkliftColleague.a", map, RequestTag.保存叉车工);
    }


}
